#include "pch.h"
#include "GraphicShape.h"
#include "GraphicDefine.h"

#include <GL/GL.h>
#include <GL/GLU.h>
#include <GL/glut.h>

CGraphicLine::CGraphicLine(const CPoint& startScreenPoint, const CPoint& endScreenPoint, const std::function<float(float, int)>& fn) : 
	CGraphicShapeBase(startScreenPoint, endScreenPoint, fn)
{
	emShape = SE_LINE;
	m_red = 1.0f;
	m_green = 0.0f;
	m_blue = 0.0f;
}

CGraphicLine::~CGraphicLine()
{

}

void CGraphicLine::Draw()
{
	glBegin(GL_LINES);
	glColor3f(m_red, m_green, m_blue);
	glVertex2f(m_startPoint.x, m_startPoint.y);
	glVertex2f(m_endPoint.x, m_endPoint.y);
	glEnd();
}

bool CGraphicLine::AtGraphBorder(const CPoint& curPoint)
{
	return OnSegment(m_startPoint, m_endPoint, 
		MyPointF{m_fnChangePos(curPoint.x, 1), m_fnChangePos(curPoint.y, 2) });
}



